package smartclass.shape;

import java.util.ArrayList;

import android.graphics.PointF;
import android.util.Log;

import com.samsung.android.sdk.pen.document.SpenObjectStroke;
import com.samsung.android.sdk.pen.document.SpenPageDoc;

public class Intersection {
	private static Intersection intersection;
	private ArrayList<PointF> arrayPoint;
	private ArrayList<PointF> arrayIntersection;
	private SpenPageDoc mSpenPageDoc;

	public Intersection(SpenPageDoc mSpenPageDoc) {
		// TODO Auto-generated constructor stub
		this.mSpenPageDoc = mSpenPageDoc;
		arrayPoint = new ArrayList<PointF>();
		arrayIntersection = new ArrayList<PointF>();
		for (int i = 0; i < mSpenPageDoc.getObjectList().size(); i++) {
			try {
				SpenObjectStroke object = (SpenObjectStroke) mSpenPageDoc
						.getObject(i);
				PointF[] points = new PointF[object.getPoints().length];
				for (int j = 0; j < object.getPoints().length; i++) {
					arrayPoint.add(points[j]);
				}
			} catch (Exception ex) {

			}
		}
		Log.e("Size SPenPageDoc", mSpenPageDoc.getObjectList().size() + " ");
	}

	public ArrayList<PointF> getIntersection(SpenObjectStroke object) {
		PointF[] point = new PointF[object.getPoints().length];
		Log.e("Size object", object.getPoints().length + " ");
		try {
			for (int i = 0; i < object.getPoints().length; i++) {
				if (arrayPoint.contains(point[i])) {
					arrayIntersection.add(point[i]);
					Log.e("InterPoint", point[i].x + "," + point[i].y);
				} else {
					arrayPoint.add(point[i]);
					Log.e("Size SPenPageDoc", mSpenPageDoc.getObjectList()
							.size() + " ");
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return arrayIntersection;
	}

}
